<template>
	<view class="min-h-full p-8 static">
		<view class="flex flex-row flex-wrap rounded-lg bg-white" style="min-height: 80vh;">
			<view class="w-full p-22 text-14" style="color: #5E5E5E;">
				<view class="text-bold text-18 bottom-line pt-10 pb-15">{{detail.name}}</view>
				<view class="bottom-line pt-12 pb-12"><text class="text-bold">订单类型：</text><text class
				="theme-color" v-if="detail.category">{{detail.category.name}}</text></view>
				<view class="bottom-line pt-12 pb-12"><text class="text-bold">订单时间：</text>{{detail.exec_at}}</view>
				<view class="bottom-line pt-12 pb-12"><text class="text-bold">订单地址：</text>{{detail.place}}</view>
				<view class="bottom-line pt-12 pb-12"><text class="text-bold">订单报酬：</text>￥{{detail.money}}</view>
				<view class="bottom-line pt-12 pb-12">
					<view class="text-bold pb-5">订单描述：</view>
					<view style="line-height: 1.25rem; white-space: pre-wrap;">{{detail.desc}}</view>
				</view>
				<view class="pt-12 pb-12">
					<view class="text-bold pb-5">订单要求：</view>
					<view style="line-height: 1.25rem; white-space: pre-wrap;" >
						{{detail.require}}
					</view>
				</view>
				
				<view v-if="detail.review_reason" class="bottom-line top-line pt-12 pb-12 mt-30">
					<view class="text-bold pb-5">审核意见：</view>
					<view style="line-height: 1.25rem; white-space: pre-wrap;">{{detail.review_reason}}</view>
				</view>
			</view>
			<view class="text-center pb-10 pt-10" style="margin: auto;">
				<image class="" src="/static/confirm-btn.jpg" style="width: 300rpx; height:85rpx" v-if="detail.task_status == 3 && detail.task_order && detail.task_order.status == 1" @tap="review"></image>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '/utils/request.js';
	export default {
		data() {
			return {
				id: '',
				detail: {},
			}
		},
		onLoad(options) {
			if(options.id){
				this.id = options.id;
				this.getTaskDetail();
			}else{
				uni.navigateBack();
			}
		},
		onReachBottom() {
			
		},
		onShareAppMessage() {
			return {
			  title: '飞兔企业版',
			  path: '/pages/task/index',
			  // imageUrl : ''
			}
		},
		onShareTimeline() {
			return {
			  title: '飞兔企业版',
			  // query: '',
			  // imageUrl : ''
			}
		},
		methods: {
			// 获取任务详情
			getTaskDetail(){
				request.post('/merchant/taskDetail', {
					id: this.id
				}).then(res=>{
					this.detail = res;
				})
			},
			// 订单通过审核
			review(){
				request.post('/merchant/reviewOrder', {
					id: this.id,
					review_status: 1
				}).then(res=>{
					uni.showToast({
						title: '确认完成成功'
					})
					this.getTaskDetail();
				})
			}
		}
	}
</script>

<style>
	page{
		background-color: #8BD1FF;
	}
	.bottom-line{
		border-bottom: 1px solid #bbb;
	}
	.top-line{
		border-top: 1px solid #bbb;
	}
</style>
